;_____________________________________________________________________
;---------------------------------------------------------------------
;	File: _Dump Build Source
;---------------------------------------------------------------------
;	Group: Overview
;
;		Copies all AHK files found within a specified folder into a 
;		specified destination folder. The global variables covered below
;		are set at the top of the script and determine the scripts root &
;		destination folder locations.
;		
;		Files/folders that begin with an underscore are ignored.
;
;_____________________________________________________________________
;---------------------------------------------------------------------
 #NoEnv
 #SingleInstance, Force
 SetWorkingDir %A_ScriptDir%
 SendMode, Input
 Functions()
;_____________________________________________________________________
;---------------------------------------------------------------------





;===================================================================================
;	Group: Gloabal Variables
;
;		List of easily customizable variables defined at the top of the script
;
;		ROOT_FOLDER 	- The root folder in which to search for all AHK files.
;					  	  Note that sub-folders will be recursed.
;		COPY_TO_FOLDER 	- Full path of the destination folder in which to
;						  make a copy of all AHK files found within ROOT_FOLDER
;===================================================================================
	ROOT_FOLDER 	= %A_ScriptDir%\..
	COPY_TO_FOLDER 	= %A_ScriptDir%\..\..\build





;=================================================================
;                  CREATE THE FOLDER IF DOESN'T EXIST
;=================================================================
	IfNotExist, %COPY_TO_FOLDER%
		FileCreateDir, %COPY_TO_FOLDER%





;=================================================================
;                      DELETE EXISTING AHK FILES
;=================================================================
	FileDelete, %COPY_TO_FOLDER%\*.*
	sleep 200






;=================================================================
;			    LOOP THROUGH INCLUDE FOLDER & SUB-FOLDERS
;=================================================================
	 Loop, %ROOT_FOLDER%\*.ahk, 1, 1
		 if !instr(A_LoopFileFullPath, "\_") && !instr(A_LoopFileFullPath, "CWI Functions") && !instr(A_LoopFileFullPath, "\Resource\")
			 FileCopy, % A_LoopFileFullPath, %COPY_TO_FOLDER%\_%A_LoopFileName%





;==========================================================================
;	    COPY THE COMPILED UPDATE (OR APPLICATION) FILE TO DUMP FOLDER
;==========================================================================
	If FileExist(ROOT_FOLDER "\PM App Launcher Update.exe"){
		FileCopy, %ROOT_FOLDER%\PM App Launcher Update.exe, %COPY_TO_FOLDER%\PM App Launcher Update.exe, 1
		Sleep 100
	} else If FileExist(ROOT_FOLDER "\PM Application Launcher.exe"){
		FileCopy, %ROOT_FOLDER%\PM Application Launcher.exe, %COPY_TO_FOLDER%\PM Application Launcher.exe, 1
		Sleep 100
	}
	
	



;=================================================================
;                   ADD INI FILE WITH VERSIONS AND TIMESTAMP
;=================================================================
	 FileDelete, %COPY_TO_FOLDER%\*.ini
	 sleep 100
	 run, %A_ScriptDir%\Version Updater.ahk -out `"%COPY_TO_FOLDER%`" -name time





;=================================================================
;	Group: About
;		- *Written By:* 	Rameen Bakhtiary
;		- *Last Modified:* 	10/24/2011
;=================================================================

;--------
sleep 100
ExitApp
;--------



















